import JsEncrypt from 'jsencrypt/bin/jsencrypt'

export function rsaEncrypt (obj, publicKey) {
  let encryptor = new JsEncrypt()
  // let publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCURjYNtDjduYvMOuiXMpskeLCcQhpw6Pp4w0s9cpccFu9NT+OxC4sYAYye1ezOz+anjyWQ0UXkVgXQs2c8P80qm7z0KkpFfdp3Pn6JCwXQ0i7fvvFMkK4DEaX/ZkQj7k1cScSjsYLRx4YRUoC5kB5bCFXJwj0zv4AWkLUrtFEwXQIDAQAB'

  encryptor.setPublicKey(publicKey)
  return encryptor.encrypt(obj)
}

/*
const PRIVTE_KEY = `-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCU7FqEqwwFdokGqLrn109kV6UzSaoA6ARYV0UlOh0J1FQBjIrQ
S2CKv66NnQ5PfFPHMb8huxoe7sJJa+t5H3V7IJv08TTggs9ZWDyEOIFWPVrJRjFZ
26exvOrzPx8QxmPAv0AvaUjQj9d6qfkqcGvPSUaVZuNIu0Jm6FhG/mHm1QIDAQAB
AoGARkUwgSFkzr8b8TR03SjPoX1pykWcHklco4KqceJ2CUlTSlfSuG6Y41+HMfNF
6WO09G0YzwXGUYo/yv1NYx3hBLwdDAVqc8oc21awDvKZCJJRcDnFqenHbleb0opq
8rjIcYaoct0FoLJ+MMfU27YaqbM3SC3hCAbV1Rq4lAfbGYECQQDEixLFVQrBBeph
xW4o+fiIMWc1367C5qVTBOHVrn9pc+82wqHpvYnPtZubM6p1K82Ad1mByRGTygy6
YhyMG6E9AkEAwflwJDRlkGBRwq5F0kThkhxqJmPZqKdq7WhJDpjj+7j/I0eIOJPw
F3YvJHJ9AoPsm/+3kGNhX/q4anInIaaFeQJBALwmLpf9q0fQ8+kY6TYM5mDqelVW
hqRJzCZHXDIE1DANLgkMFZf/PDg9MHNI6Hs2rYm3t1XJOCx0le6vEYkGwjkCQHXq
CuiHTYIxeyIsTFdg9fqa+VAy/JpQg2ikL10HRfe8YqRwlHdIPvgUKN4wFpwT1B6U
mWLVdtkgkUBr+iuzjYkCQBvwsXF3yYkbrWahqyR4VQwoVGiGasPrm5/XifCWgNVe
/SzABSqhIs4WT2BIeUQz8kFYLUIJwfeNdjfN6B80uwY=
-----END RSA PRIVATE KEY-----
`
const PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCU7FqEqwwFdokGqLrn109kV6Uz
SaoA6ARYV0UlOh0J1FQBjIrQS2CKv66NnQ5PfFPHMb8huxoe7sJJa+t5H3V7IJv0
8TTggs9ZWDyEOIFWPVrJRjFZ26exvOrzPx8QxmPAv0AvaUjQj9d6qfkqcGvPSUaV
ZuNIu0Jm6FhG/mHm1QIDAQAB
-----END PUBLIC KEY-----
`

export const _rsaEncrypt = obj => {
  let encrypt = new JsEncrypt()
  encrypt.setPublicKey(PUBLIC_KEY)
  return encrypt.encrypt(obj)
}

export const _rsaDecryption = obj => {
  let decrypt = new JsEncrypt()
  decrypt.setPrivateKey(PRIVTE_KEY)
  return decrypt.decrypt(obj)
}
*/

// export function rsaEncrypt (obj) {
//   let encryptor = new JsEncrypt();
//   let publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCURjYNtDjduYvMOuiXMpskeLCcQhpw6Pp4w0s9cpccFu9NT+OxC4sYAYye1ezOz+anjyWQ0UXkVgXQs2c8P80qm7z0KkpFfdp3Pn6JCwXQ0i7fvvFMkK4DEaX/ZkQj7k1cScSjsYLRx4YRUoC5kB5bCFXJwj0zv4AWkLUrtFEwXQIDAQAB'
//
//   encryptor.setPublicKey(publicKey)
//   return encryptor.encrypt(obj)
// }
